package com.foreknow.demo14;

import java.io.*;

/**
 * 处理流的使用
 */
public class BufferedDemo {
    public static void main(String[] args) {
        FileReader fr = null;
        BufferedReader br = null;
        FileWriter fw = null;
        BufferedWriter bw = null;
        try {
             fr = new FileReader("FileCopyDemo.java");
             br = new BufferedReader(fr);
             fw = new FileWriter("new_FileCopyDemo.java");
             bw = new BufferedWriter(fw);

            //读取源文件中的一个文本行
            String line = br.readLine();
            while(line!=null) {
                //将读取到的一个文件行写到目标文件中
                bw.write(line);
                //换行
                bw.newLine();
                line = br.readLine();
            }
            //释放资源
            br.close();
            bw.close();

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {

        }

    }
}
